Skip to content

docs: Add $cdn property to CDN Assets example#393

Merged
samdark merged 2 commits intomasterfrom
copilot/add-cdn-assets-example
Mar 16, 2026
Merged

docs: Add $cdn property to CDN Assets example#393
samdark merged 2 commits intomasterfrom
copilot/add-cdn-assets-example

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 16, 2026

The CDN Assets code example was missing the $cdn = true property, which is required to signal to the asset manager that assets are externally hosted (skipping local publishing and path resolution).

Changes

  • CDN Assets section: Added public bool $cdn = true; to the example bundle, added a short prose explanation of what the property does, added $cssOptions with SRI integrity/crossorigin to match the existing $jsOptions, and corrected the Bootstrap 5.1.3 CSS integrity hash
  • JqueryAsset example: Removed misleading // Or use CDN comment that was annotating SRI attributes unrelated to CDN usage
final class BootstrapCdnAsset extends AssetBundle
{
    public bool $cdn = true;

    public array $css = [
        'https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css',
    ];

    public array $cssOptions = [
        'integrity' => 'sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3',
        'crossorigin' => 'anonymous',
    ];

    public array $js = [
        'https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js',
    ];

    public array $jsOptions = [
        'integrity' => 'sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p',
        'crossorigin' => 'anonymous',
    ];
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Problem on "Assets"</issue_title>
<issue_description>### Description

Link to page: Assets

Please add in code expamle "CDN Assets"

public bool $cdn = true;

Package version

No response

PHP version

No response</issue_description>

<agent_instructions>Describe using CDN for assets in the assets guide.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Copilot AI changed the title [WIP] Add code example for CDN assets in assets guide docs: Add $cdn property to CDN Assets example Mar 16, 2026
Copilot AI requested a review from samdark March 16, 2026 21:06
@samdark samdark marked this pull request as ready for review March 16, 2026 21:08
Copilot AI review requested due to automatic review settings March 16, 2026 21:08
@samdark samdark merged commit 00aa088 into master Mar 16, 2026
3 checks passed
@samdark samdark deleted the copilot/add-cdn-assets-example branch March 16, 2026 21:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Assets guide to correctly document CDN-hosted asset bundles by adding the missing $cdn = true flag and aligning the Bootstrap CDN example with SRI usage expectations.

Changes:

  • Expand the “CDN Assets” section with an explanation of $cdn = true and update the example bundle accordingly.
  • Add $cssOptions (SRI integrity/crossorigin) for the Bootstrap CDN CSS resource.
  • Remove the jQuery example’s CDN-related comment and (currently) the related $jsOptions snippet.

Comment thread src/guide/views/asset.md
Comment on lines 305 to 313
final class JqueryAsset extends AssetBundle
{
public string $basePath = '@assets';
public string $baseUrl = '@assetsUrl';

public array $js = [
'js/jquery-3.6.0.min.js',
];

// Or use CDN
public array $jsOptions = [
'integrity' => 'sha256-...',
'crossorigin' => 'anonymous',
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem on "Assets"

3 participants